package com.liu.spring.framework.apo;

import com.liu.spring.framework.apo.suppport.AdvisedSupport;

/**
 * @author LIU
 * @version 1.0
 * @date 2024/5/18 17:10
 * @description 默认动态代理工程
 */
public class DefaultAopProxyFactory {
    public AopProxy createAopProxy(AdvisedSupport advised) {
        Class targetClass = advised.getTargetClass();
        Class[] interfaces = targetClass.getInterfaces();
        // 接口数量大于0，使用jdk代理
        if (interfaces.length > 0 ){
            return new JdkDynamicAopProxy(advised);
        }
        return new CglibAopProxy();
    }

}
